﻿using FutianCloudAPIService.Domains.Hanvon;
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Net;
using System.Text;

namespace FutianCloudAPIService.Handler
{
    public class HanvonModule:RavenModule
    {
        public HanvonModule():base("han")
        {
            Get["/"] = p =>
            {
                return "hello han von";
            };

            Post["/recgcard"] = p =>
            {
                string image = this.Request.Form.image;

                var webClient = new WebClient();

                using (var stream = webClient.OpenRead(image))
                {
                    using (var bmp = new Bitmap(stream))
                    {
                        return HanvonApi.Recognize(bmp);
                    }
                }
            };
        }
    }
}
